﻿/*
-----------------------------------------------------------------------------
This source file is part of Cell Cloud.

Copyright (c) 2009-2012 Cell Cloud Team (cellcloudproject@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/

#ifndef CellFileExpressDefinition_h
#define CellFileExpressDefinition_h

#include "CellPrerequisites.h"

namespace cell
{

// 默认服务端口
#define FE_PORT 7100

// 文件块大小
#define FE_CHUNK_SIZE 1048576
// 文件拆分大小
#define FE_SPLIT_SIZE 4194304

// 文件数据区大小
#define FE_FILEDATA_SIZE 7168

// Message cache size
#define FE_CACHE_SIZE 8192

// Max file name length
#define FE_MAX_FILENAME 255

// 文件权限
#define FEA_WRITE "w"
#define FEA_WRITE_DL 1
#define FEA_READ "r"
#define FEA_READ_DL 1
#define FEA_NOACCESS "no"
#define FEA_NOACCESS_DL 2
#define FEA_DML 3

// 权限校验
#define FEPT_AUTH {'A', 'U', 'T', 'H'}
#define FEPT_AUTH_B1 'A'
#define FEPT_AUTH_B2 'U'
#define FEPT_AUTH_B3 'T'
#define FEPT_AUTH_B4 'H'
#define FEPT_AUTH_ASSIGN(var) memcpy((var), "AUTH", 4)

// 拒绝操作
#define FEPT_REJECT {'R', 'E', 'J', 'T'}
#define FEPT_REJECT_B1 'R'
#define FEPT_REJECT_B2 'E'
#define FEPT_REJECT_B3 'J'
#define FEPT_REJECT_B4 'T'
#define FEPT_REJECT_ASSIGN(var) memcpy((var), "REJT", 4)

// 文件属性
#define FEPT_ATTR {'A', 'T', 'T', 'R'}
#define FEPT_ATTR_B1 'A'
#define FEPT_ATTR_B2 'T'
#define FEPT_ATTR_B3 'T'
#define FEPT_ATTR_B4 'R'
#define FEPT_ATTR_ASSIGN(var) memcpy((var), "ATTR", 4)

// 文件数据传输开始
#define FEPT_BEGIN {'B', 'E', 'G', 'N'}
#define FEPT_BEGIN_B1 'B'
#define FEPT_BEGIN_B2 'E'
#define FEPT_BEGIN_B3 'G'
#define FEPT_BEGIN_B4 'N'
#define FEPT_BEGIN_ASSIGN(var) memcpy((var), "BEGN", 4)

// 文件数据传输
#define FEPT_DATA {'D', 'A', 'T', 'A'}
#define FEPT_DATA_B1 'D'
#define FEPT_DATA_B2 'A'
#define FEPT_DATA_B3 'T'
#define FEPT_DATA_B4 'A'
#define FEPT_DATA_ASSIGN(var) memcpy((var), "DATA", 4)

// 文件数据传输确认
#define FEPT_DATA_RECEIPT {'D', 'A', 'R', 'E'}
#define FEPT_DATA_RECEIPT_B1 'D'
#define FEPT_DATA_RECEIPT_B2 'A'
#define FEPT_DATA_RECEIPT_B3 'R'
#define FEPT_DATA_RECEIPT_B4 'E'
#define FEPT_DATA_RECEIPT_ASSIGN(var) memcpy((var), "DARE", 4)

// 文件数据接收通知
#define FEPT_OFFER {'O', 'F', 'E', 'R'}
#define FEPT_OFFER_B1 'O'
#define FEPT_OFFER_B2 'F'
#define FEPT_OFFER_B3 'E'
#define FEPT_OFFER_B4 'R'
#define FEPT_OFFER_ASSIGN(var) memcpy((var), "OFER", 4)

// 文件数据传输结束
#define FEPT_END {'F', 'E', 'N', 'D'}
#define FEPT_END_B1 'F'
#define FEPT_END_B2 'E'
#define FEPT_END_B3 'N'
#define FEPT_END_B4 'D'
#define FEPT_END_ASSIGN(var) memcpy((var), "FEND", 4)

} // end namespace cell

#endif // CellFileExpressDefinition_h
